<?php
/**
 * Isu business
 * @author: NguyenTT
 */
class Plun_Business_Isu
{
    /**
     * Insert isu
     * @param $params
     * @return
     */
    public static function insertIsu($params)
    {
        try {
            //Get DB instance
            $db = Plun_Db::getInstance('master');

            //Query
            $db->insert("isu", $params);

            //Get result
            $id = $db->lastInsertId();

            //Return
            return $id;
        } catch (Exception $e) {
            throw new Plun_Exception($e->getMessage(), $e->getCode());
        }
    }

    /**
     * Update isu
     * @param $params
     * @return
     */
    public static function updateIsu($params)
    {
        try {
            //Get DB instance
            $db = Plun_Db::getInstance('master');

            //Query
            $result = $db->update("user", $params);

            //Return
            return $result;
        } catch (Exception $e) {
            throw new Plun_Exception($e->getMessage(), $e->getCode());
        }
    }

    /**
     * Delete isu
     * @param $params
     * @return
     */
    public static function deleteIsu($params)
    {
        try {
            //Get DB instance
            $db = Plun_Db::getInstance('master');

            //Query
            $result = $db->delete("isu", $params);

            //Return
            return $result;
        } catch (Exception $e) {
            throw new Plun_Exception($e->getMessage(), $e->getCode());
        }
    }

    /**
     * Get isu detail
     * @param $params
     * @return array
     */
    public static function getIsuDetail($params)
    {
        try {
            //Get DB instance
            $db = Plun_Db::getInstance('slave');

            //Query
            $stmt = $db->query("SELECT * FROM isu WHERE isu_id = '" . $params['isu_id'] . "'");

            //Get data
            $result = $stmt->fetch();

            //return data
            return $result;
        } catch (Exception $e) {
            throw new Plun_Exception($e->getMessage(), $e->getCode());
        }
    }

    
}
